<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class CommentController extends Controller
{
	//列表
    public function getIndex(Request $request)
    {
        //搜索
        $num = $request->input('num',10);
        if($request->input('id')){
            $comment = DB::table('comment')->where('id',$request->input('id'))->paginate($num);
        }else{
            $comment = DB::table('comment')->paginate($num);
        }
        
        $data = $request->all();        
        return view('admin.comment.index',['comment'=>$comment,'request'=>$data]);
    }

    //删除
    public function postDelete(Request $request)
    {
        //删除
        $id = $request->input('id');
        $res = DB::table('comment')->where('id',$id)->delete();
        //判断
        if($res){
            echo 1;
        }else{
            echo 0;
        }
    }
}
